package com.approval.approvalapp.util;

import android.content.Context;
import android.os.Looper;
import android.text.TextUtils;
import android.widget.Toast;

/**
 * Created by louyulin on 2019/3/19.
 */

public class ToastUtil {

    private static Toast toast;

    public static void showToast(Context context, String msg){
        if(toast == null && context != null){
            toast = Toast.makeText(context.getApplicationContext(), "", Toast.LENGTH_SHORT);
        }
        if(!TextUtils.isEmpty(msg) && toast != null){
            if(Thread.currentThread() == Looper.getMainLooper().getThread()){
                try {
                    toast.setText(msg);
                    toast.show();
                }catch (Exception e){

                }
            }
        }
    }


}
